import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * @author Shasha Chen  
 */
public class EnemyBullet extends Mover
{

   private static int speed = 2;
    private static int fireRate = 8;

    /**
     * Create a bullet weapon with the specified location, and direction.
     * 
     * @param x The x location within the world
     * @param y The y location within the world
     * @param direction The direction the weapon will travel
     * @param ship The ship reference that fired this weapon
     */
    public EnemyBullet()
    {
    }
    
   /* public Bullet(int speed, int x, int y, double direction)
    {
        super(speed, x, y, direction);
      
    }*/
    /**
     * Act - do whatever the Bullet wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // Add your action code here.
        //moveWeapon();
        move(9.0);
        checkCollisions();
        
        
    }    
    
    //check whether the bullet goes outside the world
    protected void checkCollisions()
    {
        if (this.getX()+10 >= getWorld().getWidth() || this.getX() <= 0 || this.getY()+10 >= getWorld().getHeight() || this.getY() <= 0)
        
        {
            removeSelf();
        }
        else
        {
            move(-4);
        }
    }
            
            
    /**
     * Removes this object from the game
     */
    protected void removeSelf()
    {
        getWorld().removeObject(this);
    }
    
     public static int speed()
    {
        return speed;
    }
    
    public static int fireRate()
    {
        return fireRate;
    }
}
